_Pragma("once");

#include <ctime>
#include <string>
#include <chrono>

namespace DateTimeUtility {
using namespace std;

using ClockTime_t = std::chrono::system_clock::duration;


constexpr ClockTime_t  TICK_COUNT_OF_DAY(24*3600*ClockTime_t::period::den);

extern const std::string DATE_TIME_FOR_READ_FORMAT;

extern  const std::string DATE_TIME_FORMAT;

extern const std::string YEAR_MOUTH_FORMAT;

extern const std::string DATE_FORMAT;


inline std::tm getTime() {
    std::time_t time = std::time(nullptr);
    return *std::localtime(&time);
}

inline std::tm toTm(const std::time_t& time) {
    return *std::localtime(&time);
}


std::string& tmFormatToString(const std::tm& dateTime, const std::string& format, std::string& result);


inline std::string& toYearMouthString(const std::tm& dateTime, std::string& result) {
    return tmFormatToString(dateTime, YEAR_MOUTH_FORMAT, result);
}



inline std::time_t toTime_t(const ClockTime_t& clockTime) {
//ClockTime_t::rep
    time_t seconds = clockTime.count() / ClockTime_t::period::den;

    return seconds;
}

inline ClockTime_t to_ClockTime(const time_t& time) {
    return ClockTime_t(time * ClockTime_t::period::den);

}


}
